<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:se="http://java.sun.com/jsf/composite/inward/search"
      xmlns:pe="http://primefaces.org/ui/extensions">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel header="Search Bills" >
                        <f:facet name="header" >
                            <h:panelGroup>
                                <h:panelGrid columns="5">
                                    <h:outputLabel value="From Date"/>
                                    <p:calendar styleClass="dateTimePicker" id="fromDate" 
                                                value="#{searchController.fromDate}" navigator="false" 
                                                pattern="dd MMMM yyyy hh mm ss a" >

                                    </p:calendar>
                                    <h:outputLabel value="To Date"/>
                                    <p:calendar id="toDate" value="#{searchController.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm ss a" >

                                    </p:calendar>
                                    <p:commandButton ajax="false" action="#{searchController.createInwardSurgeryBillsReport()}" value="Search" onclick="onSubmitButton();" />
                                    <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" onclick="onSubmitButton();" actionListener="#{mdInwardReportController.notDisBhtPySummerries()}">
                                        <pe:exporter type="xlsx" target="tblBills" fileName="surgery_details"  />
                                    </p:commandButton>
                                </h:panelGrid>

                                <h:panelGrid columns="7">
                                    <h:outputLabel value="Bill No"/>
                                    <h:outputLabel value="BHT No"/>
                                    <h:outputLabel value="Surgery Name"/>
                                    <h:outputLabel value="Perfomed Doctor Name"/>
                                    <h:outputLabel value="Patient Name"/>
                                    <h:outputLabel value="Patient Phone"/>
                                    <h:outputLabel value="Total"/>
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.billNo}" />
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.bhtNo}" />
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.itemName}" />
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.staffName}" />
                                    <p:inputText autocomplete="off" value="#{searchController.searchKeyword.patientName}" />
                                    <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.patientPhone}" />
                                    <p:inputText autocomplete="off" value="#{searchController.searchKeyword.total}"/>
                                </h:panelGrid>                                
                            </h:panelGroup>
                        </f:facet>

                        <p:dataTable id="tblBills" value="#{searchController.bills}" var="bb">

                            <p:column headerText="Bht No" >
                                <h:outputLabel value="#{bb.patientEncounter.bhtNo}" ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Room No" >
                                <h:outputLabel value="#{bb.patientEncounter.currentPatientRoom.printRoomFacilityCharge.name}" ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Surgery Name" >
                                <h:outputLabel value="#{bb.procedure.item.name}" ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Perfomed Doctor Name" >
                                <h:outputLabel value="#{bb.staff.person.name}" ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Perfomed Doctor Speciality" >
                                <h:outputLabel value="#{bb.staff.speciality.name}" ></h:outputLabel>
                            </p:column>

                            <p:column headerText="Client" >
                                <h:outputLabel value="#{bb.patientEncounter.patient.person.nameWithTitle}" ></h:outputLabel>
                            </p:column>  

                            <p:column style="text-align: right;" headerText="Surgery Value" >                              
                                <h:outputLabel value="#{bb.total}" >
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>                                  
                            </p:column>                                

                            <p:column style="text-align: right;" headerText="Bht Value" >                              
                                <h:outputLabel value="#{bb.patientEncounter.netTotal}" >
                                    <f:convertNumber pattern="#,##0.00"/>
                                </h:outputLabel>                                  
                            </p:column>      

                            <p:column headerText="Prepared At" >   
                                <h:outputLabel value="#{bb.createdAt}" />
                                <br/>
                                <h:panelGroup rendered="#{bb.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled at " />
                                    <h:outputLabel style="color: red;" rendered="#{bb.cancelled}" value="#{bb.cancelledBill.createdAt}" >
                                        <f:convertDateTime pattern="dd/MMM/yyyy - hh:mm:ss a"/>
                                    </h:outputLabel>
                                </h:panelGroup>                             
                            </p:column>

                            <p:column headerText="Prepared By">  
                                <h:outputLabel value="#{bb.creater.webUserPerson.name}" >                                      
                                </h:outputLabel>                                  
                                <br/>
                                <h:panelGroup rendered="#{bb.cancelled}" >
                                    <h:outputLabel style="color: red;" value="Cancelled By " />
                                    <h:outputLabel style="color: red;" rendered="#{bb.cancelled}" value="#{bb.cancelledBill.creater.webUserPerson.name}" >                                       
                                    </h:outputLabel>
                                </h:panelGroup>
                            </p:column>


                        </p:dataTable>

                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
